package com.yuelan.app.controller;

import com.yuelan.app.domain.RentPayOrder;
import com.yuelan.app.service.UserRentBillService;
import com.yuelan.common.annotation.Log;
import com.yuelan.common.core.controller.BaseController;
import com.yuelan.common.core.domain.AjaxResult;
import com.yuelan.common.core.page.TableDataInfo;
import com.yuelan.common.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @description: 租金信息
 * @Author: ZhaoYi
 * @date: 24-6-30 3:51
 */
@RestController
@RequestMapping("/rent")
public class UserRentController extends BaseController {

    @Autowired
    private UserRentBillService userRentBillService;



    @PostMapping
    @Log(title = "租金支付", businessType = BusinessType.INSERT)
    public AjaxResult payRent(@RequestBody RentPayOrder rentPayOrder) {
        return success();
    }


    @GetMapping("/list")
    public TableDataInfo listBill(int pageNum, int pageSize) {
        return userRentBillService.billList(pageNum, pageSize);
    }


    @GetMapping("/{id}")
    public AjaxResult view(@PathVariable Long id) {
        return success(userRentBillService.view(id));
    }


    @GetMapping("/expire")
    public AjaxResult expireBill() {
        if (userRentBillService.expireBill()) {
            return error("您有逾期账单，请及时处理！");
        }
        return success();
    }


}
